home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / LProportionalSizer / LProportionalSizer.cp next >
Encoding:
Text File  |  1997-06-30  |  3.3 KB  |  104 lines  |  [TEXT/CWIE]

  1. //**************************************************************************************
  2. // Filename:    LProportionalSizer.cp
  3. // Copyright © 1997 Dan Crevier. All rights reserved.
  4. // <mailto:Dan.Crevier@pobox.com>
  5. //
  6. // Description:    
  7. //    When this view is resized, it resizes all its subview proportionally, as if the
  8. //  view is zoomed, or shrunk
  9. //  To use it, make it as large as its enclosing view, with all of the frame bindings
  10. //    turned on.  Then put panes into the LProportionalSizer, and they will be resized
  11. //    when the superview is resized
  12. //  It was written for use with my LHiResPrintout class, but I'm sure there are other
  13. //    uses
  14. //**************************************************************************************
  15. // Revision History:
  16. // Monday, June 30, 1997 - Original
  17. //**************************************************************************************
  18.  
  19. #include "LProportionalSizer.h"
  20.  
  21. //**************************************************************************************
  22. // Function:    Default Constructor
  23. //
  24. // Description: Builds the LProportionalSizer class.
  25. //
  26. // Inputs:    none
  27. //        
  28. // Outputs:    none    
  29. //
  30. //**************************************************************************************
  31. LProportionalSizer::LProportionalSizer()
  32. {
  33. }
  34.  
  35. //**************************************************************************************
  36. // Function:    Stream Constructor
  37. //
  38. // Description: Builds the LProportionalSizer class from a PP Stream
  39. //
  40. // Inputs:    inStream
  41. //        
  42. // Outputs:    none    
  43. //
  44. //**************************************************************************************
  45. LProportionalSizer::LProportionalSizer(LStream *inStream)
  46.     : LView(inStream)
  47. {
  48. }
  49.  
  50. //**************************************************************************************
  51. // Function:    Destructor
  52. //
  53. // Description: Destroys the LProportionalSizer class.
  54. //
  55. // Inputs:    none
  56. //        
  57. // Outputs:    none    
  58. //
  59. //**************************************************************************************
  60. LProportionalSizer::~LProportionalSizer()
  61. {
  62. }
  63.  
  64. // ---------------------------------------------------------------------------
  65. //        • ResizeFrameBy
  66. // ---------------------------------------------------------------------------
  67. //    Change the Frame size by the specified amounts
  68. //
  69. //        inWidthDelta and inHeightDelta specify, in pixels, how much larger
  70. //        to make the Frame. Positive deltas increase the size, negative deltas
  71. //        reduce the size.
  72. //        Resizes subpanes proportionately
  73.  
  74. void
  75. LProportionalSizer::ResizeFrameBy(
  76.     Int16        inWidthDelta,
  77.     Int16        inHeightDelta,
  78.     Boolean        inRefresh)
  79. {
  80.     SPoint32 subLocation;
  81.     SDimension16 subSize;
  82.     SDimension16 oldSize = mFrameSize;
  83.     
  84.     LPane::ResizeFrameBy(inWidthDelta, inHeightDelta, inRefresh);
  85.  
  86.     CalcRevealedRect();
  87.     OutOfFocus(this);
  88.         
  89.     TArrayIterator<LPane*> iterator(mSubPanes);
  90.     LPane    *theSub;
  91.     while (iterator.Next(theSub)) {
  92.         theSub->GetFrameLocation(subLocation);
  93.         theSub->GetFrameSize(subSize);
  94.         theSub->ResizeFrameBy(((float)inWidthDelta)*subSize.width/oldSize.width,
  95.             ((float)inHeightDelta)*subSize.height/oldSize.height, inRefresh);
  96.         theSub->MoveBy(((float)subLocation.h)*mFrameSize.width/oldSize.width - subLocation.h,
  97.             ((float)subLocation.v)*mFrameSize.height/oldSize.height - subLocation.v, inRefresh);
  98.         //theSub->AdaptToSuperFrameSize(inWidthDelta, inHeightDelta, inRefresh);
  99.     }
  100.     
  101.     ReconcileFrameAndImage(inRefresh);
  102. }
  103.  
  104.